package converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import entity.SoapuiProject;
@FacesConverter(value="projectConverter")
public class ProjectConverter implements Converter{

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String value) {
		if(value!=null && value.length()>0){
		SoapuiProject soapuiProject = new SoapuiProject();
		soapuiProject.setName(value);
		return soapuiProject;
		}
		return null;
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		if(arg2 != null && arg2 instanceof SoapuiProject) {
			return ((SoapuiProject)arg2).getName();
		}
		return "";
	}
}

